home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / CIncludes / SoundInput.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-29  |  11.5 KB  |  285 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        SoundInput.h
  3.  
  4.      Contains:    Sound Input Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1.3
  8.  
  9.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __SOUNDINPUT__
  21. #define __SOUNDINPUT__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __APPLEEVENTS__
  30. #include <AppleEvents.h>
  31. #endif
  32. /*    #include <Errors.h>                                            */
  33. /*    #include <Memory.h>                                            */
  34. /*        #include <MixedMode.h>                                    */
  35. /*    #include <OSUtils.h>                                        */
  36. /*    #include <Events.h>                                            */
  37. /*        #include <Quickdraw.h>                                    */
  38. /*            #include <QuickdrawText.h>                            */
  39. /*    #include <EPPC.h>                                            */
  40. /*        #include <AppleTalk.h>                                    */
  41. /*        #include <Files.h>                                        */
  42. /*            #include <Finder.h>                                    */
  43. /*        #include <PPCToolbox.h>                                    */
  44. /*        #include <Processes.h>                                    */
  45. /*    #include <Notification.h>                                    */
  46.  
  47. #ifndef __WINDOWS__
  48. #include <Windows.h>
  49. #endif
  50. /*    #include <Controls.h>                                        */
  51. /*        #include <Menus.h>                                        */
  52.  
  53. #ifndef __DIALOGS__
  54. #include <Dialogs.h>
  55. #endif
  56. /*    #include <TextEdit.h>                                        */
  57.  
  58. #ifndef __FILES__
  59. #include <Files.h>
  60. #endif
  61.  
  62. #ifndef __SOUND__
  63. #include <Sound.h>
  64. #endif
  65. /*    #include <Components.h>                                        */
  66.  
  67. #ifdef __cplusplus
  68. extern "C" {
  69. #endif
  70.  
  71. #if PRAGMA_ALIGN_SUPPORTED
  72. #pragma options align=mac68k
  73. #endif
  74.  
  75. #if PRAGMA_IMPORT_SUPPORTED
  76. #pragma import on
  77. #endif
  78.  
  79. /*
  80.                         * * *  N O T E  * * *
  81.  
  82.     This file has been updated to include Sound Input Manager 1.1 interfaces.
  83.  
  84.     Some of the Sound Input Manager 1.1 interfaces were not put into the InterfaceLib
  85.     that originally shipped with the PowerMacs. These missing functions and the
  86.     new 1.1 interfaces have been released in the SoundLib library for PowerPC
  87.     developers to link with. The runtime library for these functions are
  88.     installed by Sound Manager 3.2. The following functions are found in SoundLib.
  89.  
  90.         ParseAIFFHeader(), ParseSndHeader()
  91.  
  92. */
  93.  
  94. enum {
  95.     siDeviceIsConnected            = 1,                            /*input device is connected and ready for input*/
  96.     siDeviceNotConnected        = 0,                            /*input device is not connected*/
  97.     siDontKnowIfConnected        = -1,                            /*can't tell if input device is connected*/
  98.     siReadPermission            = 0,                            /*permission passed to SPBOpenDevice*/
  99.     siWritePermission            = 1                                /*permission passed to SPBOpenDevice*/
  100. };
  101.  
  102. enum {
  103. /*Info Selectors for Sound Input Drivers*/
  104.     siActiveChannels            = 'chac',                        /*active channels*/
  105.     siActiveLevels                = 'lmac',                        /*active meter levels*/
  106.     siAGCOnOff                    = 'agc ',                        /*automatic gain control state*/
  107.     siAsync                        = 'asyn',                        /*asynchronous capability*/
  108.     siChannelAvailable            = 'chav',                        /*number of channels available*/
  109.     siCompressionAvailable        = 'cmav',                        /*compression types available*/
  110.     siCompressionFactor            = 'cmfa',                        /*current compression factor*/
  111.     siCompressionHeader            = 'cmhd',                        /*return compression header*/
  112.     siCompressionNames            = 'cnam',                        /*compression type names available*/
  113.     siCompressionType            = 'comp',                        /*current compression type*/
  114.     siContinuous                = 'cont',                        /*continous recording*/
  115.     siDeviceBufferInfo            = 'dbin',                        /*size of interrupt buffer*/
  116.     siDeviceConnected            = 'dcon',                        /*input device connection status*/
  117.     siDeviceIcon                = 'icon',                        /*input device icon*/
  118.     siDeviceName                = 'name',                        /*input device name*/
  119.     siHardwareBusy                = 'hwbs',                        /*sound hardware is in use*/
  120.     siInputGain                    = 'gain',                        /*input gain*/
  121.     siInputSource                = 'sour',                        /*input source selector*/
  122.     siInputSourceNames            = 'snam',                        /*input source names*/
  123.     siLevelMeterOnOff            = 'lmet',                        /*level meter state*/
  124.     siModemGain                    = 'mgai',                        /*modem input gain*/
  125.     siNumberChannels            = 'chan',                        /*current number of channels*/
  126.     siOptionsDialog                = 'optd',                        /*display options dialog*/
  127.     siPlayThruOnOff                = 'plth',                        /*playthrough state*/
  128.     siRecordingQuality            = 'qual',                        /*recording quality*/
  129.     siSampleRate                = 'srat',                        /*current sample rate*/
  130.     siSampleRateAvailable        = 'srav',                        /*sample rates available*/
  131.     siSampleSize                = 'ssiz',                        /*current sample size*/
  132.     siSampleSizeAvailable        = 'ssav',                        /*sample sizes available*/
  133.     siSetupCDAudio                = 'sucd',                        /*setup sound hardware for CD audio*/
  134.     siSetupModemAudio            = 'sumd',                        /*setup sound hardware for modem audio*/
  135.     siStereoInputGain            = 'sgai',                        /*stereo input gain*/
  136.     siTwosComplementOnOff        = 'twos',                        /*two's complement state*/
  137.     siVoxRecordInfo                = 'voxr',                        /*VOX record parameters*/
  138.     siVoxStopInfo                = 'voxs',                        /*VOX stop parameters*/
  139.     siCloseDriver                = 'clos',                        /*reserved for internal use only*/
  140.     siInitializeDriver            = 'init',                        /*reserved for internal use only*/
  141.     siPauseRecording            = 'paus',                        /*reserved for internal use only*/
  142.     siUserInterruptProc            = 'user',                        /*reserved for internal use only*/
  143. /*Qualities*/
  144.     siCDQuality                    = 'cd  ',                        /*44.1kHz, stereo, 16 bit*/
  145.     siBestQuality                = 'best',                        /*22kHz, mono, 8 bit*/
  146.     siBetterQuality                = 'betr',                        /*22kHz, mono, MACE 3:1*/
  147.     siGoodQuality                = 'good'
  148. };
  149.  
  150. typedef struct SPB SPB, *SPBPtr;
  151.  
  152. /*user procedures called by sound input routines*/
  153. /*
  154.         SIInterruptProcPtr uses register based parameters on the 68k and cannot
  155.         be written in or called from a high-level language without the help of
  156.         mixed mode or assembly glue.
  157.  
  158.             typedef pascal void (*SIInterruptProcPtr)(SPBPtr inParamPtr, Ptr dataBuffer, short peakAmplitude, long sampleSize);
  159.  
  160.         In:
  161.          => inParamPtr      A0.L
  162.          => dataBuffer      A1.L
  163.          => peakAmplitude    D0.W
  164.          => sampleSize      D1.L
  165. */
  166. typedef pascal void (*SICompletionProcPtr)(SPBPtr inParamPtr);
  167.  
  168. #if GENERATINGCFM
  169. typedef UniversalProcPtr SIInterruptUPP;
  170. typedef UniversalProcPtr SICompletionUPP;
  171. #else
  172. typedef Register68kProcPtr SIInterruptUPP;
  173. typedef SICompletionProcPtr SICompletionUPP;
  174. #endif
  175.  
  176. struct SPB {
  177.     long                            inRefNum;                    /*reference number of sound input device*/
  178.     unsigned long                    count;                        /*number of bytes to record*/
  179.     unsigned long                    milliseconds;                /*number of milliseconds to record*/
  180.     unsigned long                    bufferLength;                /*length of buffer in bytes*/
  181.     Ptr                                bufferPtr;                    /*buffer to store sound data in*/
  182.     SICompletionUPP                    completionRoutine;            /*completion routine*/
  183.     SIInterruptUPP                    interruptRoutine;            /*interrupt routine*/
  184.     long                            userLong;                    /*user-defined field*/
  185.     OSErr                            error;                        /*error*/
  186.     long                            unused1;                    /*reserved - must be zero*/
  187. };
  188. extern pascal NumVersion SPBVersion(void)
  189.  FOURWORDINLINE(0x203C, 0x0000, 0x0014, 0xA800);
  190. extern pascal OSErr SndRecord(ModalFilterUPP filterProc, Point corner, OSType quality, SndListHandle *sndHandle)
  191.  FOURWORDINLINE(0x203C, 0x0804, 0x0014, 0xA800);
  192. extern pascal OSErr SndRecordToFile(ModalFilterUPP filterProc, Point corner, OSType quality, short fRefNum)
  193.  FOURWORDINLINE(0x203C, 0x0708, 0x0014, 0xA800);
  194. extern pascal OSErr SPBSignInDevice(short deviceRefNum, ConstStr255Param deviceName)
  195.  FOURWORDINLINE(0x203C, 0x030C, 0x0014, 0xA800);
  196. extern pascal OSErr SPBSignOutDevice(short deviceRefNum)
  197.  FOURWORDINLINE(0x203C, 0x0110, 0x0014, 0xA800);
  198. extern pascal OSErr SPBGetIndexedDevice(short count, Str255 deviceName, Handle *deviceIconHandle)
  199.  FOURWORDINLINE(0x203C, 0x0514, 0x0014, 0xA800);
  200. extern pascal OSErr SPBOpenDevice(ConstStr255Param deviceName, short permission, long *inRefNum)
  201.  FOURWORDINLINE(0x203C, 0x0518, 0x0014, 0xA800);
  202. extern pascal OSErr SPBCloseDevice(long inRefNum)
  203.  FOURWORDINLINE(0x203C, 0x021C, 0x0014, 0xA800);
  204. extern pascal OSErr SPBRecord(SPBPtr inParamPtr, Boolean asynchFlag)
  205.  FOURWORDINLINE(0x203C, 0x0320, 0x0014, 0xA800);
  206. extern pascal OSErr SPBRecordToFile(short fRefNum, SPBPtr inParamPtr, Boolean asynchFlag)
  207.  FOURWORDINLINE(0x203C, 0x0424, 0x0014, 0xA800);
  208. extern pascal OSErr SPBPauseRecording(long inRefNum)
  209.  FOURWORDINLINE(0x203C, 0x0228, 0x0014, 0xA800);
  210. extern pascal OSErr SPBResumeRecording(long inRefNum)
  211.  FOURWORDINLINE(0x203C, 0x022C, 0x0014, 0xA800);
  212. extern pascal OSErr SPBStopRecording(long inRefNum)
  213.  FOURWORDINLINE(0x203C, 0x0230, 0x0014, 0xA800);
  214. extern pascal OSErr SPBGetRecordingStatus(long inRefNum, short *recordingStatus, short *meterLevel, unsigned long *totalSamplesToRecord, unsigned long *numberOfSamplesRecorded, unsigned long *totalMsecsToRecord, unsigned long *numberOfMsecsRecorded)
  215.  FOURWORDINLINE(0x203C, 0x0E34, 0x0014, 0xA800);
  216. extern pascal OSErr SPBGetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  217.  FOURWORDINLINE(0x203C, 0x0638, 0x0014, 0xA800);
  218. extern pascal OSErr SPBSetDeviceInfo(long inRefNum, OSType infoType, void *infoData)
  219.  FOURWORDINLINE(0x203C, 0x063C, 0x0014, 0xA800);
  220. extern pascal OSErr SPBMillisecondsToBytes(long inRefNum, long *milliseconds)
  221.  FOURWORDINLINE(0x203C, 0x0440, 0x0014, 0xA800);
  222. extern pascal OSErr SPBBytesToMilliseconds(long inRefNum, long *byteCount)
  223.  FOURWORDINLINE(0x203C, 0x0444, 0x0014, 0xA800);
  224. extern pascal OSErr SetupSndHeader(SndListHandle sndHandle, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, short baseNote, unsigned long numBytes, short *headerLen)
  225.  FOURWORDINLINE(0x203C, 0x0D48, 0x0014, 0xA800);
  226. extern pascal OSErr SetupAIFFHeader(short fRefNum, short numChannels, UnsignedFixed sampleRate, short sampleSize, OSType compressionType, unsigned long numBytes, unsigned long numFrames)
  227.  FOURWORDINLINE(0x203C, 0x0B4C, 0x0014, 0xA800);
  228.  
  229.  
  230. /* Sound Input Manager 1.1 and later calls */
  231. extern pascal OSErr ParseAIFFHeader(short fRefNum, SoundComponentData *sndInfo, unsigned long *numFrames, unsigned long *dataOffset)
  232.  FOURWORDINLINE(0x203C, 0x0758, 0x0014, 0xA800);
  233.  
  234. extern pascal OSErr ParseSndHeader(SndListHandle sndHandle, SoundComponentData *sndInfo, unsigned long *numFrames, unsigned long *dataOffset)
  235.  FOURWORDINLINE(0x203C, 0x085C, 0x0014, 0xA800);
  236.  
  237.  
  238. enum {
  239.     uppSIInterruptProcInfo = kRegisterBased
  240.          | REGISTER_ROUTINE_PARAMETER(1, kRegisterA0, SIZE_CODE(sizeof(SPBPtr)))
  241.          | REGISTER_ROUTINE_PARAMETER(2, kRegisterA1, SIZE_CODE(sizeof(Ptr)))
  242.          | REGISTER_ROUTINE_PARAMETER(3, kRegisterD0, SIZE_CODE(sizeof(short)))
  243.          | REGISTER_ROUTINE_PARAMETER(4, kRegisterD1, SIZE_CODE(sizeof(long))),
  244.     uppSICompletionProcInfo = kPascalStackBased
  245.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SPBPtr)))
  246. };
  247.  
  248. #if GENERATINGCFM
  249. #define NewSIInterruptProc(userRoutine)        \
  250.         (SIInterruptUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSIInterruptProcInfo, GetCurrentArchitecture())
  251. #define NewSICompletionProc(userRoutine)        \
  252.         (SICompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSICompletionProcInfo, GetCurrentArchitecture())
  253. #else
  254. #define NewSIInterruptProc(userRoutine)        \
  255.         ((SIInterruptUPP) (userRoutine))
  256. #define NewSICompletionProc(userRoutine)        \
  257.         ((SICompletionUPP) (userRoutine))
  258. #endif
  259.  
  260. #if GENERATINGCFM
  261. #define CallSIInterruptProc(userRoutine, inParamPtr, dataBuffer, peakAmplitude, sampleSize)        \
  262.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSIInterruptProcInfo, (inParamPtr), (dataBuffer), (peakAmplitude), (sampleSize))
  263. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  264.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSICompletionProcInfo, (inParamPtr))
  265. #else
  266. /* (*SIInterruptProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  267. #define CallSICompletionProc(userRoutine, inParamPtr)        \
  268.         (*(userRoutine))((inParamPtr))
  269. #endif
  270.  
  271.  
  272. #if PRAGMA_IMPORT_SUPPORTED
  273. #pragma import off
  274. #endif
  275.  
  276. #if PRAGMA_ALIGN_SUPPORTED
  277. #pragma options align=reset
  278. #endif
  279.  
  280. #ifdef __cplusplus
  281. }
  282. #endif
  283.  
  284. #endif /* __SOUNDINPUT__ */
  285.